// import { defineStore } from "pinia"
const useStore = new defineStore('shop', {
  state()
  {
    return {
      business: {
        id: 0,
        mobile: "",
        nickname: "",
        password: "",
        avatar: "",
        gender: "0",
        sourceid: 0,
        deal: "0",
        openid: null,
        province: "",
        city: "",
        district: "",
        createtime: 0,
        money: "0",
        email: "",
        auth: "0",
        poster: "",
        parentid: '0',
        gender_text: "保密",
        mobile_text: "",
        avatar_text: "",
        poster_text: "",
        deal_text: "未成交",
        auth_text: "未认证",
        region_text: "",
        province_text: "",
        city_text: "",
        district_text: "",
        createtime_text: ""
      },
      address: null,
      link: null,
    }
  },
  persist: {
    enabled: true,//开启数据持久化
    strategies: [
      {
        key: 'shop',//给一个要保存的名称
        storage: localStorage,//sessionStorage / localStorage 存储方式
      }
    ]
  },
})

export default{
  install(app)
  {
    const store = useStore()
    const {business, address, link} = storeToRefs(store)
    //挂载到全局中
    app.config.globalProperties.$business = business
    app.config.globalProperties.$address = address
    app.config.globalProperties.$link = link
    
    app.config.globalProperties.$store = store
  }
}
